#!/usr/bin/env python
#coding:utf8

import os, sys
import logging
import pybcs
import argparse
import ConfigParser

def get_config_path():
    return os.path.expanduser('~/.bcsh')
    
def load_cfg():
    cfg_file = get_config_path()
    config = ConfigParser.ConfigParser()
    cfg = config.read(cfg_file)
    #args={'AK':'','SK':''}
    #print config.get('bcs', 'AK')
    args = {
    	'AK' : config.get('bcs', 'AK'),
    	'SK' : config.get('bcs', 'SK')
    	}
    return args

def gen_url(bucket,file,mode=0):
	args = load_cfg()
	bcs = pybcs.BCS('http://bcs.duapp.com/', args['AK'], args['SK'], pybcs.PyCurlHTTPC)
	return bcs.sign("GET",bucket,file)

BUCKET = ''

if __name__ == "__main__":
	for arg in sys.argv[1:]: 
		print "====================================="
		print "file: "+arg
		print gen_url(BUCKET,arg)
    	